<template>
	<view style="display: flex;width: 100%; height: 100%; align-items: center;justify-content: center;">
		<view
			style="width: 50%; height: 50%; box-shadow: 10rpx 10rpx 30rpx black; border-radius: 30rpx; display: flex;justify-content: center;align-items: center;">
			<view style="width: 60%;">
				<uni-easyinput placeholder="请填写账号" v-model="username"></uni-easyinput>
				<uni-easyinput placeholder="请填写密码" style="margin-top: 50rpx;" type="password"
					v-model="password"></uni-easyinput>
				<button type="primary" style="margin-top: 50rpx;" @click="loginsubmit">登录</button>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		postrequest
	} from '../../common/apis.js';
	import whtMd5 from '@/uni_modules/wht-md5/js_sdk/wht-md5.js'

	export default {
		name: "login",
		data() {
			return {
				username: 'admin',
				password: '12345689'
			};
		},
		methods: {
			loginsubmit() {
				let data = {
					username: this.username,
					password: whtMd5(this.password),
				}
				let url = 'https://www.jsyufang.com/yiXun/api/adminlogin/index.asp'
				let errmessage = '调用登录接口失败'
				postrequest(url, data, errmessage, true)
					.then((res) => {
						if (res.data.code == 0) {
							uni.setStorageSync('username', this.username)
							uni.setStorageSync('password', whtMd5(this.password))
							this.$emit('submit', 'loginsucces')
						}
					})
			}
		}
	}
</script>

<style>

</style>